﻿<!--revision $Id$-->
<Window x:Class="OpenWPFChart.Helpers.ItemPropertiesDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sys="clr-namespace:System;assembly=mscorlib"
	xmlns:parts="clr-namespace:OpenWPFChart.Parts;assembly=OpenWPFChart.Parts"
	xmlns:local="clr-namespace:OpenWPFChart.Helpers"
	Name="theDialog"
	Style="{DynamicResource dialogWindow}"
    Title="Chart Item Properties" 
	MinWidth="150" MinHeight="100" WindowStartupLocation="CenterOwner"
	FocusManager.FocusedElement="{Binding ElementName=txtItemName}"
	>

	<Window.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../DialogStyle.xaml"/>
			</ResourceDictionary.MergedDictionaries>
			
			<BooleanToVisibilityConverter x:Key="boolToVisibility"/>
			<local:IntegerToVisibilityConverter x:Key="intToVisibility"/>

			<ObjectDataProvider x:Key="bubbleLabelAlignment"
						MethodName="GetValues" 
						ObjectType="{x:Type sys:Enum}">
				<ObjectDataProvider.MethodParameters>
					<x:Type TypeName="parts:BubbleLabelAlignment" />
				</ObjectDataProvider.MethodParameters>
			</ObjectDataProvider>

			<!--Interpolated Item Template-->
			<DataTemplate x:Key="interpolatedItem">
				<TextBlock>
					<TextBlock.Text>
						<Binding>
							<Binding.Converter>
								<local:InterpolatedVisualDescrptionConverter/>
							</Binding.Converter>
						</Binding>
					</TextBlock.Text>
				</TextBlock>
			</DataTemplate>
			
			<!--SampledCurveDataView Template-->
			<DataTemplate DataType="{x:Type parts:SampledCurveDataView}">
				<TabControl Grid.Row="1">

					<TabItem Header="Curve">
						<Grid>
							<Grid.RowDefinitions>
								<!-- Interpolator row -->
								<RowDefinition Height="Auto"/>
								<!-- Curve Color row -->
								<RowDefinition Height="Auto"/>
								<!-- Curve Thickness row -->
								<RowDefinition Height="Auto"/>
								<!-- FillArea row -->
								<RowDefinition Height="Auto"/>
								<!-- AreaBrush row -->
								<RowDefinition Height="Auto"/>
								<!-- PointMarker Visible row -->
								<RowDefinition Height="Auto"/>
								<!-- PointMarker row -->
								<RowDefinition/>
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition />
							</Grid.ColumnDefinitions>

							<!-- Interpolator row -->
							<Label Target="{Binding ElementName=lbxVisualCue}"
								Visibility="{Binding ElementName=theDialog,
									Path=InterpolatedVisuals.Count, 
									Converter={StaticResource intToVisibility}}">
								Interpolator
							</Label>
							<ListBox Grid.Column="1" Name="lbxVisualCue"
								ItemsSource="{Binding ElementName=theDialog, Path=InterpolatedVisuals}"
								ItemTemplate="{StaticResource interpolatedItem}"
								SelectedItem="{Binding ElementName=theDialog, Path=InterpolatedVisual}"
								ToolTip="Select the Interpolator"
								Visibility="{Binding ElementName=theDialog, 
									Path=InterpolatedVisuals.Count, 
									Converter={StaticResource intToVisibility}}"/>

							<!-- Curve Color row -->
							<Label Grid.Row="1" Target="{Binding ElementName=btnCurveColor}">Curve Color</Label>
							<Button Grid.Row="1" Grid.Column="1" Name="btnCurveColor" 
								Command="{Binding ElementName=theDialog, Path=SelectCurveColorCommand}" 
								ToolTip="Click to select Curve Color">
									<Rectangle Width="50" Height="17" Fill="{Binding Path=Pen.Brush}"/>
							</Button>

							<!-- Curve Thickness row -->
							<Label Grid.Row="2" Target="{Binding ElementName=txtCurveThickness}">Curve Thickness</Label>
							<TextBox Grid.Row="2" Grid.Column="1" Name="txtCurveThickness" 
								Text="{Binding Path=Pen.Thickness, UpdateSourceTrigger=PropertyChanged,
									ValidatesOnExceptions=True, ValidatesOnDataErrors=True}" 
								ToolTip="Edit Curve Thickness value">
							</TextBox>

							<!-- FillArea row -->
							<CheckBox Grid.Row="3" Grid.ColumnSpan="2" 
									  IsChecked="{Binding Path=FillArea}"
									  VerticalAlignment="Center" HorizontalAlignment="Left"
									  Content="Fill the Area" FlowDirection="RightToLeft"
									  Margin="5"/>

							<!-- AreaBrush row -->
							<Label Grid.Row="4" Target="{Binding ElementName=btnAreaBrush}">Area Brush</Label>
							<Button Grid.Row="4" Grid.Column="1" Name="btnAreaBrush" 
								Command="{Binding ElementName=theDialog, Path=SelectAreaBrushCommand}" 
								ToolTip="Click to select Area Brush">
								<Rectangle Width="50" Height="17" Fill="{Binding Path=AreaBrush}"/>
							</Button>

							<!-- PointMarkerVisible row -->
							<CheckBox Grid.Row="5" Grid.ColumnSpan="2" 
									  IsChecked="{Binding Path=PointMarkerVisible}"
									  VerticalAlignment="Center" HorizontalAlignment="Left"
									  Content="Show PointMarker" FlowDirection="RightToLeft"
									  Margin="5"/>

							<!-- PointMarker row -->
							<Label Grid.Row="6" Target="{Binding ElementName=btnPointMarker}">Point Marker</Label>
							<Button Grid.Row="6" Grid.Column="1" Name="btnPointMarker" 
								Command="{Binding ElementName=theDialog, Path=PointMarkerPropertiesCommand}" 
								ToolTip="Click to Edit Point Marker Properties">
								<Image Stretch="None">
									<Image.Source>
										<DrawingImage Drawing="{Binding PointMarker}"/>
									</Image.Source>
								</Image>
							</Button>
						</Grid>
					</TabItem>

					<TabItem Name="hScaleTab" 
							 Header="{Binding ElementName=theDialog, Path=HorizontalScaleTabHeader}"
							 Visibility="{Binding ElementName=theDialog,
								Path=ShowHorizontalScaleProperties, 
								Converter={StaticResource boolToVisibility}}">
						<local:ChartScaleControl x:Name="hScale"
							ChartScale="{Binding Path=HorizontalScale}"
							CanChangeChartScaleType="{Binding ElementName=theDialog, Path=CanChangeHorizontalScaleType}"/>
					</TabItem>

					<TabItem Name="vScaleTab"
							 Header="{Binding ElementName=theDialog, Path=VerticalScaleTabHeader}"
							 Visibility="{Binding ElementName=theDialog,
								Path=ShowVerticalScaleProperties,	
								Converter={StaticResource boolToVisibility}}">
						<local:ChartScaleControl x:Name="vScale"
							ChartScale="{Binding Path=VerticalScale}"
							CanChangeChartScaleType="{Binding ElementName=theDialog, Path=CanChangeVerticalScaleType}"/>
					</TabItem>
				</TabControl>
			</DataTemplate>
			
			<!--ScatteredPointsDataView Template-->
			<DataTemplate DataType="{x:Type parts:ScatteredPointsDataView}">
				<TabControl Grid.Row="1">

					<TabItem Header="Marker">
						<Grid>
							<Grid.RowDefinitions>
								<!-- PointMarker row -->
								<RowDefinition/>
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition />
							</Grid.ColumnDefinitions>

							<!-- PointMarker row -->
							<Label Target="{Binding ElementName=btnPointMarker}">Point Marker</Label>
							<Button Grid.Column="1" Name="btnPointMarker" 
								Command="{Binding ElementName=theDialog, Path=PointMarkerPropertiesCommand}" 
								ToolTip="Click to Edit Point Marker Properties">
								<Image Stretch="None">
									<Image.Source>
										<DrawingImage Drawing="{Binding PointMarker}"/>
									</Image.Source>
								</Image>
							</Button>
						</Grid>
					</TabItem>

					<TabItem Name="hScaleTab" 
							 Header="{Binding ElementName=theDialog, Path=HorizontalScaleTabHeader}"
							 Visibility="{Binding ElementName=theDialog,
								Path=ShowHorizontalScaleProperties, 
								Converter={StaticResource boolToVisibility}}">
						<local:ChartScaleControl x:Name="hScale"
							ChartScale="{Binding Path=HorizontalScale}"
							CanChangeChartScaleType="{Binding ElementName=theDialog, Path=CanChangeHorizontalScaleType}"/>
					</TabItem>

					<TabItem Name="vScaleTab"
							 Header="{Binding ElementName=theDialog, Path=VerticalScaleTabHeader}"
							 Visibility="{Binding ElementName=theDialog,
								Path=ShowVerticalScaleProperties,	
								Converter={StaticResource boolToVisibility}}">
						<local:ChartScaleControl x:Name="vScale"
							ChartScale="{Binding Path=VerticalScale}"
							CanChangeChartScaleType="{Binding ElementName=theDialog, Path=CanChangeVerticalScaleType}"/>
					</TabItem>
				</TabControl>
			</DataTemplate>
			
			<!--BubblePointsDataView Template-->
			<DataTemplate DataType="{x:Type parts:BubblePointsDataView}">
				<TabControl Grid.Row="1">

					<TabItem Header="Bubble">
						<Grid>
							<Grid.RowDefinitions>
								<!-- Bubble row -->
								<RowDefinition Height="Auto"/>
								<!-- LabelAlignment row -->
								<RowDefinition Height="Auto"/>
								<!-- ScaleLabelToBubbleSize row -->
								<RowDefinition Height="Auto"/>
								<!-- LabelFormat row -->
								<RowDefinition Height="Auto"/>
								<!-- LabelBrush row -->
								<RowDefinition Height="Auto"/>
								<!-- Font row -->
								<RowDefinition/>
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition />
							</Grid.ColumnDefinitions>

							<!-- Bubble row -->
							<Label Grid.Row="0" Target="{Binding ElementName=btnBubble}">Bubble</Label>
							<Button Grid.Row="0" Grid.Column="1" Name="btnBubble" 
								Command="{Binding ElementName=theDialog, Path=BubblePropertiesCommand}" 
								ToolTip="Click to Edit Bubble Properties">
								<Image Stretch="None">
									<Image.Source>
										<DrawingImage Drawing="{Binding Bubble}"/>
									</Image.Source>
								</Image>
							</Button>

							<!-- LabelAlignment row -->
							<Label Grid.Row="1" Target="{Binding ElementName=cbxBubbleLabelAlignment}">Label Alignment</Label>
							<ComboBox Grid.Row="1" Grid.Column="1" Name="cbxBubbleLabelAlignment"
									  ItemsSource="{Binding Source={StaticResource bubbleLabelAlignment}}"
									  SelectedItem="{Binding Path=LabelAlignment}"
									  IsSynchronizedWithCurrentItem="True"/>

							<!-- ScaleLabelToBubbleSize row -->
							<CheckBox Grid.Row="2" Grid.ColumnSpan="2" 
									  IsChecked="{Binding Path=ScaleLabelToBubbleSize}"
									  VerticalAlignment="Center" HorizontalAlignment="Left"
									  Content="Scale Label to Bubble" FlowDirection="RightToLeft"
									  Margin="5"/>

							<!-- LabelFormat row -->
							<Label Grid.Row="3" Target="{Binding ElementName=txtLabelFormat}">Label Format</Label>
							<TextBox Grid.Row="3" Grid.Column="1" Name="txtLabelFormat" 
								Text="{Binding Path=LabelFormat, UpdateSourceTrigger=PropertyChanged,
									ValidatesOnExceptions=True, ValidatesOnDataErrors=True}" 
								ToolTip="Edit Label Format">
							</TextBox>

							<!-- LabelBrush row -->
							<Label Grid.Row="4" Target="{Binding ElementName=btnLabelBrush}">Label Brush</Label>
							<Button Grid.Row="4" Grid.Column="1" Name="btnLabelBrush" 
								Command="{Binding ElementName=theDialog, Path=SelectLabelBrushCommand}" 
								ToolTip="Click to select Label Brush">
								<Rectangle Width="50" Height="17" Fill="{Binding Path=LabelBrush}"/>
							</Button>

							<!-- Font row -->
							<Label Grid.Row="5" Target="{Binding ElementName=btnFont}">Font</Label>
							<Button Grid.Row="5" Grid.Column="1" Name="btnFont"
									Command="{Binding ElementName=theDialog, Path=ChooseBubbleLabelFontCommand}" 
									FontFamily="{Binding Path=FontFamily}"
									FontSize="{Binding Path=FontSize}"
									FontStretch="{Binding Path=FontStretch}"
									FontStyle="{Binding Path=FontStyle}"
									FontWeight="{Binding Path=FontWeight}"
									>
								Choose Font
							</Button>
						</Grid>
					</TabItem>

					<TabItem Name="hScaleTab" 
							 Header="{Binding ElementName=theDialog, Path=HorizontalScaleTabHeader}"
							 Visibility="{Binding ElementName=theDialog,
								Path=ShowHorizontalScaleProperties, 
								Converter={StaticResource boolToVisibility}}">
						<local:ChartScaleControl x:Name="hScale"
							ChartScale="{Binding Path=HorizontalScale}"
							CanChangeChartScaleType="{Binding ElementName=theDialog, Path=CanChangeHorizontalScaleType}"/>
					</TabItem>

					<TabItem Name="vScaleTab"
							 Header="{Binding ElementName=theDialog, Path=VerticalScaleTabHeader}"
							 Visibility="{Binding ElementName=theDialog,
								Path=ShowVerticalScaleProperties,	
								Converter={StaticResource boolToVisibility}}">
						<local:ChartScaleControl x:Name="vScale"
							ChartScale="{Binding Path=VerticalScale}"
							CanChangeChartScaleType="{Binding ElementName=theDialog, Path=CanChangeVerticalScaleType}"/>
					</TabItem>

					<TabItem Name="zScaleTab"
							 Header="{Binding ElementName=theDialog, Path=ZScaleTabHeader}"
							 Visibility="{Binding ElementName=theDialog,
								Path=ShowZScaleProperties,	
								Converter={StaticResource boolToVisibility}}">
						<local:ChartScaleControl x:Name="zScale"
							ChartScale="{Binding Path=ZScale}"
							CanChangeChartScaleType="{Binding ElementName=theDialog, Path=CanChangeZScaleType}"/>
					</TabItem>
				</TabControl>
			</DataTemplate>

			<!--ColumnChartItemDataView Template-->
			<DataTemplate DataType="{x:Type parts:ColumnChartItemDataView}">
				<TabControl Grid.Row="1">

					<TabItem Header="Curve">
						<Grid>
							<Grid.RowDefinitions>
								<!-- ColumnWidth row -->
								<RowDefinition Height="Auto"/>
								<!-- ColumnBrush row -->
								<RowDefinition Height="Auto"/>
								<!-- IsCurveVisible row -->
								<RowDefinition Height="Auto"/>
								<!-- Interpolator row -->
								<RowDefinition Height="Auto"/>
								<!-- Curve Color row -->
								<RowDefinition Height="Auto"/>
								<!-- Curve Thickness row -->
								<RowDefinition Height="Auto"/>
								<!-- PointMarker Visible row -->
								<RowDefinition Height="Auto"/>
								<!-- PointMarker row -->
								<RowDefinition/>
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition />
							</Grid.ColumnDefinitions>

							<!-- ColumnWidth row -->
							<Label Grid.Row="0" Target="{Binding ElementName=txtColumnWidth}">Column Width</Label>
							<TextBox Grid.Row="0" Grid.Column="1" Name="txtColumnWidth" 
								Text="{Binding Path=ColumnWidth, UpdateSourceTrigger=PropertyChanged,
									ValidatesOnExceptions=True, ValidatesOnDataErrors=True}" 
								ToolTip="Edit Column Width value">
							</TextBox>

							<!-- ColumnBrush row -->
							<Label Grid.Row="1" Target="{Binding ElementName=btnColumnBrush}">Column Color</Label>
							<Button Grid.Row="1" Grid.Column="1" Name="btnColumnBrush" 
								Command="{Binding ElementName=theDialog, Path=SelectColumnBrushCommand}" 
								ToolTip="Click to select Column Brush">
								<Rectangle Width="50" Height="17" Fill="{Binding Path=ColumnBrush}"/>
							</Button>

							<!-- IsCurveVisible row -->
							<CheckBox Grid.Row="2" Grid.ColumnSpan="2" 
									  IsChecked="{Binding Path=IsCurveVisible}"
									  VerticalAlignment="Center" HorizontalAlignment="Left"
									  Content="Is Curve Visible" FlowDirection="RightToLeft"
									  Margin="5"/>

							<!-- Interpolator row -->
							<Label Grid.Row="3" Target="{Binding ElementName=lbxVisualCue}"
								Visibility="{Binding ElementName=theDialog,
									Path=InterpolatedVisuals.Count, 
									Converter={StaticResource intToVisibility}}">
								Interpolator
							</Label>
							<ListBox Grid.Row="3" Grid.Column="1" Name="lbxVisualCue"
								ItemsSource="{Binding ElementName=theDialog, Path=InterpolatedVisuals}"
								ItemTemplate="{StaticResource interpolatedItem}"
								SelectedItem="{Binding ElementName=theDialog, Path=InterpolatedVisual}"
								ToolTip="Select the Interpolator"
								Visibility="{Binding ElementName=theDialog, 
									Path=InterpolatedVisuals.Count, 
									Converter={StaticResource intToVisibility}}"/>

							<!-- Curve Color row -->
							<Label Grid.Row="4" Target="{Binding ElementName=btnCurveColor}">Curve Color</Label>
							<Button Grid.Row="4" Grid.Column="1" Name="btnCurveColor" 
								Command="{Binding ElementName=theDialog, Path=SelectCurveColorCommand}" 
								ToolTip="Click to select Curve Color">
								<Rectangle Width="50" Height="17" Fill="{Binding Path=Pen.Brush}"/>
							</Button>

							<!-- Curve Thickness row -->
							<Label Grid.Row="5" Target="{Binding ElementName=txtCurveThickness}">Curve Thickness</Label>
							<TextBox Grid.Row="5" Grid.Column="1" Name="txtCurveThickness" 
								Text="{Binding Path=Pen.Thickness, UpdateSourceTrigger=PropertyChanged,
									ValidatesOnExceptions=True, ValidatesOnDataErrors=True}" 
								ToolTip="Edit Curve Thickness value">
							</TextBox>

							<!-- PointMarkerVisible row -->
							<CheckBox Grid.Row="6" Grid.ColumnSpan="2" 
									  IsChecked="{Binding Path=PointMarkerVisible}"
									  VerticalAlignment="Center" HorizontalAlignment="Left"
									  Content="Show PointMarker" FlowDirection="RightToLeft"
									  Margin="5"/>

							<!-- PointMarker row -->
							<Label Grid.Row="7" Target="{Binding ElementName=btnPointMarker}">Point Marker</Label>
							<Button Grid.Row="7" Grid.Column="1" Name="btnPointMarker" 
								Command="{Binding ElementName=theDialog, Path=PointMarkerPropertiesCommand}" 
								ToolTip="Click to Edit Point Marker Properties">
								<Image Stretch="None">
									<Image.Source>
										<DrawingImage Drawing="{Binding PointMarker}"/>
									</Image.Source>
								</Image>
							</Button>
						</Grid>
					</TabItem>

					<TabItem Name="hScaleTab" 
							 Header="{Binding ElementName=theDialog, Path=HorizontalScaleTabHeader}"
							 Visibility="{Binding ElementName=theDialog,
								Path=ShowHorizontalScaleProperties, 
								Converter={StaticResource boolToVisibility}}">
						<local:ChartScaleControl x:Name="hScale"
							ChartScale="{Binding Path=HorizontalScale}"
							CanChangeChartScaleType="{Binding ElementName=theDialog, Path=CanChangeHorizontalScaleType}"/>
					</TabItem>

					<TabItem Name="vScaleTab"
							 Header="{Binding ElementName=theDialog, Path=VerticalScaleTabHeader}"
							 Visibility="{Binding ElementName=theDialog,
								Path=ShowVerticalScaleProperties,	
								Converter={StaticResource boolToVisibility}}">
						<local:ChartScaleControl x:Name="vScale"
							ChartScale="{Binding Path=VerticalScale}"
							CanChangeChartScaleType="{Binding ElementName=theDialog, Path=CanChangeVerticalScaleType}"/>
					</TabItem>
				</TabControl>
			</DataTemplate>
		</ResourceDictionary>
	</Window.Resources>

	<DockPanel>
		<!-- Dialog buttons row -->
		<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" 
					HorizontalAlignment="Right" VerticalAlignment="Bottom">
			<Button Name="btnOK" Click="btnOK_Click"  Style="{StaticResource dialogButton}" IsDefault="True" IsEnabled="False">OK</Button>
			<Button Style="{StaticResource dialogButton}" IsCancel="True">Cancel</Button>
		</StackPanel>
		
		<!-- Item Name -->
		<Grid DockPanel.Dock="Top" Margin="0 0 0 5">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"/>
				<ColumnDefinition/>
			</Grid.ColumnDefinitions>

			<Label Target="{Binding ElementName=txtItemName}">Item Name</Label>
			<TextBox Grid.Column="1" Name="txtItemName" 
				Text="{Binding Path=ItemData.ItemName, UpdateSourceTrigger=PropertyChanged}"/>
		</Grid>

		<ContentControl Content="{Binding}"/>
	</DockPanel>
</Window>
